﻿@using Abp.Authorization.Users
@using DevM.Web.Startup
@model DevM.Web.Models.Projects.ProjectListViewModel
@{
    ViewBag.CurrentPageName = PageNames.Projects; // The menu item will be active for this page.
}
@section scripts
{
    <script src="~/js/boostrap-pagination.js"></script>
    <script src="~/view-resources/Views/Projects/Index.js" asp-append-version="true"></script>
}
<style>
    /*去点栅格自带的 margin*/
    .card .body .col-xs-12, .card .body .col-sm-12, .card .body .col-md-12, .card .body .col-lg-12 {
        margin-bottom: unset;
    }

    .card .body .col-xs-4, .card .body .col-sm-4, .card .body .col-md-4, .card .body .col-lg-4 {
        margin-bottom: unset;
    }

    /*动态列表*/
    #create-project-dynamicinfo .input-group {
        margin-bottom: 0px;
    }

    .dynamicinfo-information {
        text-overflow: ellipsis;
        white-space: nowrap;
        overflow: hidden;
        margin-bottom: unset;
    }
</style>
<div class="row clearfix">
    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
        <div class="card">
            <div class="header">
                <h2>
                    @L("Projects")
                </h2>
                <ul class="header-dropdown m-r--5">
                    <li class="dropdown">
                        <a href="javascript:void(0);" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
                            <i class="material-icons">more_vert</i>
                        </a>
                        <ul class="dropdown-menu pull-right">
                            <li><a id="RefreshButton" href="javascript:void(0);" class="waves-effect waves-block"><i class="material-icons">refresh</i>@L("Refresh")</a></li>
                        </ul>
                    </li>
                </ul>
            </div>
            <div class="body table-responsive">

                <div>
                    @foreach (var project in Model.Projects.Items)
                    {
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                <span>
                                    @L("Project")：@project.Name
                                </span>
                                <ul class="header-dropdown m-r--5 pull-right" style="list-style-type:none">
                                    <li class="dropdown">
                                        <a href="javascript:void(0);" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
                                            <i class="material-icons">menu</i>
                                        </a>
                                        <ul class="dropdown-menu pull-right">
                                            <li>
                                                <a href="#" class="waves-effect waves-block edit-project" data-project-id="@project.Id" data-toggle="modal" data-target="#ProjectEditModal"><i class="material-icons">edit</i>@L("Edit")</a>
                                            </li>
                                            <li>
                                                <a href="#" class="waves-effect waves-block delete-project" data-project-id="@project.Id" data-project-name="@project.Name"><i class="material-icons">delete_sweep</i>@L("Delete")</a>
                                            </li>
                                            <li>
                                                <a href="#" class="waves-effect waves-block add-dynamicinfo" data-project-id="@project.Id" data-toggle="modal" data-target="#DynamicInfoCreateModal"><i class="glyphicon glyphicon-info-sign">&nbsp;</i>@L("AddDynamicInfo")</a>
                                            </li>
                                            <li>
                                                <a href="@Url.Action("Environments","Projects")?projectId=@project.Id" class="waves-effect waves-block"><i class="glyphicon glyphicon-hdd">&nbsp;</i>@L("EditEnvironment")</a>
                                            </li>
                                            <li>
                                                <a href="@Url.Action("Index","ReleaseRecord")?projectId=@project.Id" class="waves-effect waves-block"><i class="glyphicon glyphicon-transfer">&nbsp;</i>@L("ReleaseRecords")</a>
                                            </li>
                                            <li>
                                                <a href="@Url.Action("ReleaseLogs","ReleaseRecord")?projectId=@project.Id" class="waves-effect waves-block"><i class="glyphicon glyphicon-time">&nbsp;</i>@L("ReleaseLogs")</a>
                                            </li>

                                        </ul>
                                    </li>
                                </ul>
                            </div>
                            <div class="panel-body">
                                <div class="row clearfix">
                                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">

                                        <p>@L("Introduction")：@project.Introduction</p>
                                    </div>
                                    <div class="col-lg-3 col-md-4 col-sm-12 col-xs-12">
                                        <p>@L("MemberRoleName")：@project.RoleName</p>
                                    </div>
                                    <div class="col-lg-3 col-md-4 col-sm-12 col-xs-12">
                                        <p>@L("TotalEnvironment")：@project.TotalEnvironment</p>
                                    </div>

                                    <div class="col-lg-3 col-md-4 col-sm-12 col-xs-12">

                                        <p>@L("CreationTime")：@project.CreationTime</p>
                                    </div>
                                </div>
                                <br />
                                <p class="dynamicinfo-loading dynamicinfo-container" data-project-id="@project.Id">

                                </p>



                            </div>
                        </div>
                    }
                </div>
                <nav aria-label="Page navigation">
                    <ul class="pagination" data-total="@Model.Projects.TotalCount">
                        <li>
                            <a href="#" aria-label="Previous">
                                <span aria-hidden="true">&laquo;</span>
                            </a>
                        </li>
                        <li class="active"><a href="#">1</a></li>
                        <li><a href="#">2</a></li>
                        <li><a href="#">3</a></li>
                        <li><a href="#">4</a></li>
                        <li><a href="#">5</a></li>
                        <li>
                            <a href="#" aria-label="Next">
                                <span aria-hidden="true">&raquo;</span>
                            </a>
                        </li>
                    </ul>
                </nav>
                <button type="button" class="btn btn-primary btn-circle waves-effect waves-circle waves-float pull-right" data-toggle="modal" data-target="#ProjectCreateModal">
                    <i class="material-icons">add</i>
                </button>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" id="ProjectCreateModal" tabindex="-1" role="dialog" aria-labelledby="UserCreateModalLabel" data-backdrop="static">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title">
                    <span>@L("CreateNewProject")</span>
                </h4>
            </div>
            <div class="modal-body">
                <form name="userCreateForm" role="form" novalidate class="form-validation">
                    <ul class="nav nav-tabs tab-nav-right" role="tablist">
                        <li role="presentation" class="active"><a href="#create-project-details" data-toggle="tab">@L("ProjectDetails")</a></li>
                        <li role="presentation"><a href="#create-project-roles" data-toggle="tab">@L("MemberRole")</a></li>
                    </ul>
                    <div class="tab-content">
                        <div role="tabpanel" class="tab-pane animated fadeIn active" id="create-project-details">
                            <div class="row clearfix" style="margin-top:10px;">
                                <div class="col-sm-12">
                                    <div class="form-group form-float">
                                        <div class="form-line">
                                            <input class="form-control" type="text" name="Name" required maxlength="200" minlength="2">
                                            <label class="form-label">@L("Name")</label>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="row clearfix">
                                <div class="col-sm-12">
                                    <div class="form-group form-float">
                                        <div class="form-line">
                                            <textarea type="text" name="Introduction" class="form-control" required maxlength="2000"></textarea>
                                            <label class="form-label">@L("Introduction")</label>
                                        </div>
                                    </div>
                                </div>
                            </div>

                        </div>
                        <div role="tabpanel" class="tab-pane animated fadeIn" id="create-project-roles">
                            <div class="row">
                                <div class="col-sm-12 ">
                                    @foreach (var role in Model.Roles)
                                    {
                                        <div class="col-sm-6">
                                            <input type="radio" name="MemberRoleId" value="@role.Id" title="@role.Description" class="filled-in" id="role-@role.Id" />
                                            <label for="role-@role.Id" title="@role.DisplayName">@role.Name</label>
                                        </div>
                                    }
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default waves-effect" data-dismiss="modal">@L("Cancel")</button>
                        <button type="submit" class="btn btn-primary waves-effect">@L("Save")</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="ProjectEditModal" tabindex="-1" role="dialog" aria-labelledby="UserEditModalLabel" data-backdrop="static">
    <div class="modal-dialog" role="document">
        <div class="modal-content">

        </div>
    </div>
</div>

<div class="modal fade" id="DynamicInfoCreateModal" tabindex="-1" role="dialog" aria-labelledby="UserCreateModalLabel" data-backdrop="static">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title">
                    <span>@L("CreateNewDynamicInfo")</span>
                </h4>
            </div>
            <div class="modal-body">
                <form name="dynamicInfoCreateForm" role="form" novalidate class="form-validation">
                    <input type="hidden" name="projectId" value="" />
                    <ul class="nav nav-tabs tab-nav-right" role="tablist">
                        <li role="presentation" class="active"><a href="#create-feedback-details" data-toggle="tab">@L("DynamicInfoDetails")</a></li>
                        <li role="presentation" class=""><a href="#create-project-dynamicinfo" data-toggle="tab">@L("DynamicInfoResources")</a></li>
                    </ul>
                    <div class="tab-content">
                        <div role="tabpanel" class="tab-pane animated fadeIn active" id="create-feedback-details">

                            <div class="row clearfix">
                                <div class="col-sm-12">
                                    <div class="form-group form-float">
                                        <div class="form-line">
                                            <textarea type="text" name="Information" class="form-control" required maxlength="2000"></textarea>
                                            <label class="form-label">@L("Information")</label>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <!--resource-->


                        <div role="tabpanel" class="tab-pane animated fadeIn " id="create-project-dynamicinfo">

                            <script type="text/template" class="add-resource-template">
                                <!--resource template-->
                                <div class="input-group">
                                    <div class="input-group">
                                        <span class="input-group-btn">
                                            <button class="btn btn-xs btn-default btn-select-resource" type="button">@L("SelectResource")</button>
                                        </span>
                                        <input type="text" class="form-control" readonly placeholder="@L("ResourceName") ...">
                                    </div><!-- /input-group -->
                                    <input type="file" style="display:none" class="form-control" name="resource">
                                    <span class="input-group-btn">
                                        <button class="btn btn-xs btn-danger btn-remove-resource" type="button">@L("Remove")</button>
                                    </span>
                                </div><!-- /input-group -->
                            </script>

                            <button class="btn btn-ms btn-primary add-resource" type="button">
                                @L("AddResource")
                            </button>
                            <br />
                            <br />

                            <div class="row clearfix">
                                <div class="col-sm-12">
                                    <div class="add-resource-container">
                                        <!--模板填充-->
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default waves-effect" data-dismiss="modal">@L("Cancel")</button>
                        <button type="submit" class="btn btn-primary waves-effect">@L("Save")</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<!--文件模板-->
<script type="text/template" id="dynamicinfo-templte">
    <ul class="list-group">
        <li class="list-group-item">
            <a href="#">
                <p class="dynamicinfo-information">
                    <i class="glyphicon glyphicon-paperclip dynamicinfo-totalresource">.</i>
                </p>
            </a>
            <p class="dynamicinfo-creationtime"></p>
        </li>
    </ul>
</script>